import Mock from 'mockjs';
export default {
  getMenu: config => {
    const { username, password } = JSON.parse(config.body);
    console.log(JSON.parse(config.body));
    // 先判断用户是否存在
    if (username === 'admin' || username === 'wp') {
      // 判断账号和密码是否对应
      if (username === 'admin' && password === '123456') {
        return {
          code: 20000,
          data: {
            menu: [
              {
                path: '/',
                name: 'home',
                label: '首页',
                icon: 's-home',
                url: 'Home/Home'
              },
              {
                label: 'ZC数据管理',
                icon: 'video-play',
                children: [
                  {
                    path: '/TheGlobalQuantity',
                    name: 'theGlobalQuantity',
                    label: '全球星',
                    url: 'TheGlobalQuantity/index'
                  },
                  {
                    path: '/CollectiFDataFiles',
                    name: 'collectiFDataFiles',
                    label: '采集中频数据文件',
                    url: 'CollectiFDataFiles/index'
                  },
                  {
                    path: '/RestoreThePostInformationMaterialFile',
                    name: 'restoreThePostInformationMaterialFile',
                    label: '还原后信息素材文件',
                    url: 'RestoreThePostInformationMaterialFile/index'
                  }
                ]
              },
              {
                label: '目标知识管理',
                icon: 'video-play',
                children: [
                  {
                    path: '/PlatformTargetKnowledgeManagement',
                    name: 'PlatformTargetKnowledgeManagement',
                    label: '平台目标知识管理',
                    url: 'PlatformTargetKnowledgeManagement/index'
                  },
                  {
                    path: '/MobileTerminalTargeKnowledgeManagement',
                    name: 'MobileTerminalTargeKnowledgeManagement',
                    label: '移动终端目标知识管理',
                    url: 'MobileTerminalTargeKnowledgeManagement/index'
                  },
                  {
                    path: '/RegionalSpecificKnowledgeManagement',
                    name: 'RegionalSpecificKnowledgeManagement',
                    label: '特定区域知识管理',
                    url: 'RegionalSpecificKnowledgeManagement/index'
                  }
                ]
              }
            ],
            token: Mock.Random.guid(),
            message: '获取成功'
          }
        };
      } else if (username === 'wp' && password === '123456') {
        return {
          code: 20000,
          data: {
            menu: [
              {
                path: '/',
                name: 'home',
                label: '首页',
                icon: 's-home',
                url: 'Home/Home'
              },
              {
                path: '/video',
                name: 'video',
                label: '视频管理页',
                icon: 'video-play',
                url: 'VideoManage/VideoManage'
              }
            ],
            token: Mock.Random.guid(),
            message: '获取成功'
          }
        };
      } else {
        return {
          code: -999,
          data: {
            message: '密码错误'
          }
        };
      }
    } else {
      return {
        code: -999,
        data: {
          message: '用户不存在'
        }
      };
    }
  }
};
